package com.example.service;

import com.example.mapper.LeaveMapper;
import com.example.pojo.Leave;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LeaveService {

    @Autowired
    private LeaveMapper leaveMapper;

    public List<Leave> getLeavesByEmployeeId(String employeeId) {
        return leaveMapper.getLeavesByEmployeeId(employeeId);
    }

    public void applyLeave(Leave leave) {
        leaveMapper.applyLeave(leave);
    }

    public Leave getLeaveById(String leaveId) {

        return leaveMapper.getLeaveById(leaveId);
    }

    public int getApprovedLeaveDaysForMonth(String employeeId, int year, int month) {
        Integer days = leaveMapper.getApprovedLeaveDaysForMonth(employeeId, year, month);
        return days == null ? 0 : days;
    }
}
